<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />
        <title>11.验证</title>
        <!-- 引入Vue -->
        <script src="../js/vue.js"></script>
    </head>
    <style>
        span{
            font-size: 10px;
            color: #666;
        }
    </style>
    <body>
        <!-- 准备好一个容器-->
        <div id="app">
            <form action="">
                账号：<input type="text" v-model="userid" /> <span>{{regUserid}}</span>  <br><br>
                密码：<input type="password" v-model="password" /> <span>{{regPassword}}</span>  <br><br>
                手机号：<input type="text" v-model="phone" /> <span>{{regPhone}}</span>  <br><br>
                姓名：<input type="text" v-model="username" /> <span>{{regUsername}}</span>  <br><br>
            </form>
        </div>
    </body>

    <script>
        new Vue({
            el:"#app",
            data:{
                userid: "",
                password: "",
                phone: "",
                username: ""
            },
            computed:{
                regUserid(){
                    // 正则
                    let Reg = /[0-9a-zA-Z]{6,12}$/;
                    return Reg.test(this.userid) ? "ok" : "请输入正确的号码"                   
                },
                regPassword(){
                    let Reg = /[0-9a-zA-Z]{6,12}$/;
                    return Reg.test(this.password) ? "ok" : "请输入正确的密码"
                },
                regPhone(){
                    let Reg = /^1(358|4[456789]|6[67]|7[0135678]|9[1589])\d{8}$/;
                    return Reg.test(this.phone) ? "ok" : "请输入正确的手机号码"
                },
                regUsername(){
                    let Reg = /^[\u4e00-\u9fa5]{0,}$/
                    return Reg.test(this.username) ? "ok" : "请输入正确的密码"
                }
            }
        })
    </script>
</html>